//
//  UIBarButtonItem+Category.swift
//  WeiBoOfSwift
//
//  Created by aven wu on 20/04/2018.
//  Copyright © 2018 GML. All rights reserved.
//

import Foundation
import UIKit
extension UIBarButtonItem {
    class func creatCustomBarButtonItem(imageName:String,highlightedName:String,title:String,target:Any?,action:Selector) -> UIBarButtonItem{
        // 创建按钮
        let rightBtn = UIButton()
        rightBtn.setImage(UIImage(named:imageName), for: UIControlState.normal)
        rightBtn.setImage(UIImage(named:highlightedName), for: UIControlState.highlighted)
        rightBtn.setTitle(title, for: UIControlState.normal)
        rightBtn.setTitleColor(UIColor.orange, for: UIControlState.normal)
        rightBtn.sizeToFit()
        rightBtn.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        rightBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        return UIBarButtonItem.init(customView: rightBtn)
    }
}
